<?php
/*========================================= JooSam =========================================/
/																							/
/	Extention:		JooSam																	/
/	Created by:		ScriptPlanet.eu															/
/	Site:			http://www.scriptplanet.eu												/
/	Email:			support@scriptplanet.eu													/
/	Support:		http://www.scriptplanet.eu/support										/
/	Copyright:		2011 (c) ScriptPlanet.eu												/
/	License:		CC BY-NC-ND 3.0 ~ http://creativecommons.org/licenses/by-nc-nd/3.0/		/
/	File Version:	0001																	/
/																							/
/========================================== JooSam ========================================*/
// Joomla security
defined('_JEXEC') or die;

jimport('joomla.application.component.view');

class JoosamViewJoosam extends JView{
	
	function display($tpl = null){

		## Build songdata object
		$data = new jsamSongdata();

		## some vars
		$songid = JRequest::getVar('spstring');
		$layoutType = JRequest::getVar('sptype');

		## Get data
		$info = $data->getInfo('songinfo', $songid);
		$counter = $data->getInfo('count', '');
		$letter = $data->getInfo('letter', '');
		$picture = $data->getInfo('picture', $songid);
		$introtext = $data->getInfo('introtext', '');

		if (count($errors = $this->get('Errors'))){
			JError::raiseError(500, implode('<br />', $errors));
			return false;
		}

		## Links
		$this->info = $info;
		$this->counter = $counter;
		$this->letter = $letter;
		$this->picture = $picture;
		$this->layout = $layoutType;
		$this->songid = $songid;
		$this->introtext = $introtext;


		$this->setDocument();
		// Display the view
		parent::display($tpl);
	}

	protected function setDocument(){
		$css = new jsamCssWork();
		$thisPageTarget = JRequest::getVar('limitstart', 0);
		$thisLetterTarget = JRequest::getVar('spstring');
		$colora = $css->rowbgcolor("colora");
		$colorb = $css->rowbgcolor("colorb");
		$colorc = $css->rowbgcolor("colorc");
		$document = JFactory::getDocument();
		$document->addScript(JURI::root() . "administrator/components/com_joosam/javascript/jQuery/jquery.core.js");
		$document->addScript(JURI::root() . "administrator/components/com_joosam/javascript/jQuery/ui.core.js");
		$document->addScript(JURI::root() . "administrator/components/com_joosam/javascript/jQuery/ui.widget.js");
		$document->addScript(JURI::root() . "administrator/components/com_joosam/javascript/jQuery/ui.position.js");
		$document->addScript(JURI::root() . "administrator/components/com_joosam/javascript/jQuery/ui.autocomplete.js");
		$document->addStyleSheet( 'administrator/components/com_joosam/themes/jquery.ui.css' );
		$document->addStyleDeclaration( '
			#jslett'.$thisLetterTarget.'{ border-radius:4px; border:1px solid; background:none; }
			#jspBut'.$thisPageTarget.'{ border-radius:4px; border:1px solid; }
			.spBGTabel{ background:'.$colorc.'; }
			.jspBG0{ background:'.$colora.'; }
			.jspBG1{ background:'.$colorb.'; }
			.ui-autocomplete-loading{
				background-color:none;
				background-image: url(../media/com_joosam/images/rotor.gif);
				background-position:right center;
				background-repeat:no-repeat;
			}
		');
	}
}